<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js">
    </script>
</head>

<body>
    <script>
        var app = angular.module('myApp', []);
        // 创建控制器,可将$soupe对象作为参数传递
        app.controller('myCtrl', function ($scope) {
            $scope.carname = "Volvo";
        });

        // 创建控制器时，将rootScope作为参数传递
        app.controller('myCtrl', function ($scope, $rootScope) {
            $scope.names = ["Emil", "Tobias", "Linus"];
            $rootScope.lastname = "Refsnes";
        });
    </script>
    <div ng-app="myApp" ng-controller="myCtrl">
        <h1>{{carname}}</h1>
    </div>

</body>

</html>